module App::Controller
    class DbusAdaptor < Qt::DBusAbstractAdaptor
        slots :trayIconActivated

        def initialize(app)
            super(app)

            # qdbusviewer, session bus..
            raise "Cannot connect to the D-BUS session bus" unless Qt::DBusConnection::sessionBus.connected?
            raise "Qt::DBusConnection.sessionBus.registerService: #{Qt::DBusConnection.sessionBus.lastError.message}" unless
                    Qt::DBusConnection.sessionBus.registerService("org.kde.Ktoggl2")
            Qt::DBusConnection.sessionBus.registerObject("/", self, Qt::DBusConnection::ExportAllSlots)
        end

        def trayIconActivated()
            $widget.trayIconActivated
        end
    end
end
